﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using IntfClass;

namespace IntfSetting.FrmIntf
{
    public partial class FrmFreStep6 : Form
    {
        public FrmFreStep6(string ParentID)
        {
            InitializeComponent();
            if (!ParentID.Equals(string.Empty))
            {
                //blnNew = false;
                strParentID = ParentID;

            }
        }
       
        public DataTable dtGridView = new DataTable();
        //public ArrayList arrMonthDay = new ArrayList();
        private string strParentID = string.Empty;
        private void btnNew_Click(object sender, EventArgs e)
        {
            FrmFreStep7 frmFreStep7 = new FrmFreStep7(string.Empty);
            if (frmFreStep7.ShowDialog() == DialogResult.OK)
            {
                DataRow drRow = dtGridView.NewRow();
                drRow["StartTime"] = frmFreStep7.strTime;
                dtGridView.Rows.Add(drRow);
            }

        }

        private void SearchStartTime()
        {
            StringBuilder strSql = new StringBuilder();
            if (strParentID.Equals(string.Empty))
            {
                strSql.AppendLine("select * from TRuleList t where t.ParentID = 0");
            }
            else
            {
                strSql.AppendLine("select * from TRuleList t where t.ParentID = " + strParentID);
            }
            ClassDB classDB = new ClassDB();
            dtGridView = classDB.ExecuteDataTable(strSql.ToString());

        }

        private void FrmFreStep6_Load(object sender, EventArgs e)
        {
            SearchStartTime();
            this.dataGridView1.DataSource = dtGridView;
            dataGridView1.Columns[0].Visible = false;
            dataGridView1.Columns[1].Visible = false;
            dataGridView1.Columns[2].Visible = true;

            dataGridView1.Columns[2].ReadOnly = true;

            dataGridView1.Columns[2].HeaderText = "开始时间";

        }

        private void btnUpt_Click(object sender, EventArgs e)
        {
            FrmFreStep7 frmFreStep7 = new FrmFreStep7(dataGridView1.SelectedRows[0].Cells["StartTime"].Value.ToString());
            if (frmFreStep7.ShowDialog() == DialogResult.OK)
            {
                dataGridView1.SelectedRows[0].Cells["StartTime"].Value = frmFreStep7.strTime;
                //dtGridView.Rows[dataGridView1.SelectedRows[0].Index]["StartTime"] = frmFreStep7.strTime;
            }
        }

        private void btnDel_Click(object sender, EventArgs e)
        {
            dtGridView.Rows.RemoveAt(dataGridView1.SelectedRows[0].Index);
        }

    }
}
